//
//  UserData.swift
//  maozzi-rss
//
//  Created by 帽子 on 2020/5/23.
//  Copyright © 2020 帽子. All rights reserved.
//  项目中各个数据统一暂存点

import Combine
import SwiftUI

final class UserData: ObservableObject {
    // 系统多数据源
    static let datasources: [DatasourceItem] = FileUtil.load("datasources.geojson")
    // 加载用户选择的数据源
    @Published var userDatasources = (UserDefaults.standard.array(forKey: "userDatasources") ?? []) as [String]
    static let readCacheFileName = "read.json"
    static let recentCacheFileName = "recent.json"
    @Published var newsData = RSSUtil.get()
    @Published var recentData: [NewsItem] = LocalCacheUtil.getAll(filename: recentCacheFileName)
    @Published var show = false
    // 未读列表row 样式，2-两栏；3-三栏
    @Published var unreadListStyle = UserDefaults.standard.integer(forKey: "unreadListStyle") == 0 ? 2 : UserDefaults.standard.integer(forKey: "unreadListStyle")
    // 全局开/关黑暗模式，0-关闭；1-开启，2-自动
    @Published var interfaceStyle = UserDefaults.standard.integer(forKey: "interfaceStyle")
}
